{% set pypi_name = 'cliff' %}
{% set upstream_version = upstream_version('3.5.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Command Line Interface Formulation Framework
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PrettyTable') }}
BuildRequires:  {{ py3('PyYAML') }}
BuildRequires:  {{ py3('cmd2') }}
BuildRequires:  {{ py3('docutils') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pytest') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('stevedore') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('cmd2') }}
Requires:       {{ py3('pyparsing') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}
BuildArch:      noarch

%description
cliff is a framework for building command line programs. It uses
setuptools entry points to provide subcommands, output formatters, and
other extensions.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Command Line Interface Formulation Framework
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('cmd2') }}
Requires:       {{ py3('pyparsing') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}

%description -n {{ py2name(py_versions='py3') }}
cliff is a framework for building command line programs. It uses
setuptools entry points to provide subcommands, output formatters, and
other extensions.

This package contains the Python 3.x module.

%package -n python-cliff-doc
Summary:        %{summary} - Documentation
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n python-cliff-doc
cliff is a framework for building command line programs. It uses
setuptools entry points to provide subcommands, output formatters, and
other extensions.

This package contains documentation files for %{name}.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%py3_build
PBR_VERSION={{ upstream_version }} PYTHONPATH=. %sphinx_build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%py3_install

%check
# doesn't work with pytest atm
rm -v cliff/tests/test_commandmanager.py
python3 -m pytest cliff/tests

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc ChangeLog README.rst
%{python3_sitelib}/{{ pypi_name }}
%{python3_sitelib}/*.egg-info

%files -n python-cliff-doc
%license LICENSE
%doc doc/build/html

%changelog
